package com.gdust.hzx.manager.controller;

import com.gdust.hzx.manager.service.FileUploadService;
import com.gdust.hzx.model.vo.common.Result;
import com.gdust.hzx.model.vo.common.ResultCodeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * ClassName: FileUploadController
 * Package: com.gdust.spzx.manager.controller
 * Description:
 *
 * @Author syun
 * @Create 2024/11/23 17:19
 * @Version 1.0
 */
@RestController
@RequestMapping("/admin/system")
public class FileUploadController {
    @Autowired
    private FileUploadService fileUploadService;


    /**
     * 用户头像上传接口
     * @param file 上传文件
     * @return 响应结果实体类返回结果与业务状态码
     */
    @PostMapping("/fileUpload")
    public Result<String> upload(@RequestParam MultipartFile file){
        //1 获取上传的文件
        //2 调用service的方法上传，返回腾讯云路径
        String url = fileUploadService.upload(file);
        return Result.build(url, ResultCodeEnum.SUCCESS);
    }


}
